{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">渠道管理</li>
            <li class=""><a href="{:url('/admin/channel/add')}">添加渠道</a></li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                <form class="layui-form layui-form-pane" action="{:url('/admin/channel')}" method="get">
                    <div class="layui-inline">
                        <label class="layui-form-label">用户名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword" value="{$keyword}" placeholder="请输入关键词" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn">搜索</button>
                    </div>
                </form>
                <hr>

                <table class="layui-table">
                    <thead>
                    <tr>
                        <th >ID</th>
                        <th>用户名</th>
                     	<th>昵称</th>
                     	<th>游戏平台</th>
                     	<th>电子邮箱</th>
                     	<th>手机号</th>
                     	{/*<th>余额</th>*/}
                     	{/*<th style="width: 80px;">预付金</th>*/}
                        <th>支付方式</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach name="user_list" item="vo"}
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.username}</td>
                        <td>{$vo.nickname}</td>
                        <td>{$vo.platform}</td>
                        <td>{$vo.email}</td>
                        <td>{$vo.mobile}</td>
                        <td>{eq name="$vo.pay_where" value="0"}自有支付{/eq}{eq name="$vo.pay_where" value="1"}渠道支付{/eq}</td>
                        {/*<td>{$vo.balance&cc;</td>*/}
                       	<!--<td class="layui-form">
						    <div class="layui-form layui-form-item">
  								<input lay-skin="switch" lay-filter="status" type="checkbox" {eq name="$vo.yufujin_status" value="1"}checked="" name="open"{else/}name="close"{/eq} lay-skin="switch" lay-text="开启|关闭" table-value="user" field-value="yufujin_status" key-value="id" id-value="{$vo.id}" status-value="{$vo.yufujin_status}">
							</div>
						</td>-->
                        <td class="layui-form">
						    <div class="layui-form layui-form-item">
  								<input lay-skin="switch" lay-filter="status" type="checkbox" {eq name="$vo.status" value="1"}checked="" name="open"{else/}name="close"{/eq} lay-skin="switch" lay-text="开启|关闭" table-value="channel" field-value="status" key-value="id" id-value="{$vo.id}" status-value="{$vo.status}">
							</div>
						</td>
                        <td>
                            <a href="{:url('/admin/channel/edit',['id'=>$vo['id']])}" class="layui-btn layui-btn-normal layui-btn-mini">编辑</a>
                            <a href="{:url('/admin/channel/delete',['id'=>$vo['id']])}" class="layui-btn layui-btn-danger layui-btn-mini ajax-delete">删除</a>
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
                <!--分页-->
                {$user_list|raw}
            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>

layui.use('form', function(){
    var form = layui.form;
    laydate = layui.laydate;

    form.on('switch(status)',function(data){
        var id = $(this).attr('data');
        var type = this.checked ? 1:0;
        var tp = 'gstatus';
        var url  = $(this).attr('data-url');
        $.post(url,{id:id,tp:tp,val:type},function(info){
            layer.msg(info.msg);
        })
    });
});

layui.use('form', function(){
  var form = layui.form;
      laydate = layui.laydate;
	form.on('switch(status)',function(data){
        var url = "{:url('/admin/checkstatus')}";

    	var id=($(data.elem).attr('id-value'));
	    var table=($(data.elem).attr("table-value"));
        var field=($(data.elem).attr("field-value"));
        var key=($(data.elem).attr("key-value"));
       $.get(url,{id:id,table:table,field:field,key:key},function(info){
           layer.msg(info.info);
    	});
	});
});
</script>
{/block}